<html>
<title>
Call webservice with javascript and xmlhttp.
</title>
<body>
<script language="javascript">

//Test function with get method.
function RequestByGet(data){

var xmlhttp = null;
if(window.ActiveXObject){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
   xmlhttp=new XMLHttpRequest();
}

//Webservice location.
var URL="http://www.adobetes.com/f4iaw100/remoteData/EmployeeData.cfc?wsdl";
xmlhttp.open("GET",URL, false);
xmlhttp.setRequestHeader ("Content-Type","application/x-www-form-urlencoded");
xmlhttp.setRequestHeader ("SOAPAction","http://dao.wfservice.ws.emolay.com");
alert(xmlhttp);
xmlhttp.send(null);
var result = xmlhttp.status;
alert(result);
//OK
if(result==200) {
alert(xmlhttp.responseText);
//document.write();
}
xmlhttp = null;
}

//Test function with post method
function RequestByPost(value)
{
/*
下面data拼接的是soap xml文件，其中soap:Body标签中的getWsLogByTaskid标签是自己定义的webservice方法，
http://dao.wfservice.ws.emolay.com是要访问的webservice的命名空间即nimespace的值；
taskid标签是要访问的方法的参数名称即getWsLogByTaskid(String taskid)中的taskid，value为传递的参数的值
*/
var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
data = data + '<soap:Body>';
data = data + '<getEmployees xmlns="http://dao.wfservice.ws.emolay.com">';
data = data + '</getEmployees>';
data = data + '</soap:Body>';
data = data + '</soap:Envelope>';

var xmlhttp = null;
if(window.ActiveXObject){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
   xmlhttp=new XMLHttpRequest();
}
var URL="http://www.adobetes.com/f4iaw100/remoteData/EmployeeData.cfc?wsdl";//该url是访问的webservice的地址
xmlhttp.open("POST",URL, false);
xmlhttp.setRequestHeader ("Content-Type","text/xml; charset=utf-8");
xmlhttp.setRequestHeader ("SOAPAction","http://dao.wfservice.ws.emolay.com");//设置SOAPAction的值也就是访问的webservice的命名空间
xmlhttp.send(data);
//alert();
document.getElementById("result").innerHTML=xmlhttp.responseText;
}

</Script>

<input type="button" value="CallWebserviceByGet" onClick="RequestByGet(null)">
<input type="button" value="CallWebserviceByPost" onClick="RequestByPost('jbpm$37')">
<div id="result"></div>
</body>

</html>